//
//  DetailViewController.m
//  UI_通讯_26
//
//  Created by dllo on 15/11/21.
//  Copyright © 2015年 liwenhan. All rights reserved.
//

#import "DetailViewController.h"
#import "WriteViewController.h"
#import "DetailView.h"
#import "CoreDataManager.h"

@interface DetailViewController ()

@property (nonatomic, strong)DetailView *detailView;

@property (nonatomic, strong)CoreDataManager *manager;

@end

@implementation DetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    

    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"编辑" style:UIBarButtonItemStylePlain target:self action:@selector(writeAction:)];
    
    // 建好的view
    self.detailView = [[DetailView alloc]initWithFrame:CGRectMake(0, 64, self.view.frame.size.width, self.view.frame.size.height)];
    [self.view addSubview:self.detailView];
    
       
    
    // 赋值
    self.detailView.nameLabel.text = self.chuanPerson.name;
    self.detailView.phonedLabel.text = self.chuanPerson.phone;
    self.detailView.numberdLabel.text = self.chuanPerson.number;
    self.detailView.citydLabel.text = self.chuanPerson.city;
    self.detailView.qqdLabel.text = self.chuanPerson.qq;

    
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    
    // 赋值
    self.detailView.nameLabel.text = self.chuanPerson.name;
    self.detailView.phonedLabel.text = self.chuanPerson.phone;
    self.detailView.numberdLabel.text = self.chuanPerson.number;
    self.detailView.citydLabel.text = self.chuanPerson.city;
    self.detailView.qqdLabel.text = self.chuanPerson.qq;
    
    
    
}


// 编辑按钮
- (void)writeAction:(UIBarButtonItem *)item
{
    WriteViewController *writeVC = [[WriteViewController alloc]init];
    writeVC.twoChuanPerson = self.chuanPerson;
    writeVC.j = self.i;
    
    // 这么跳转没有controller
    [self.navigationController presentViewController:writeVC animated:YES completion:^{
        
    }];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
